<template>
  <div>
    <el-row>
      <el-col :span="24">
        <div class="search-box">
          <!-- <el-form :inline="true" size="medium">
            <el-form-item>
              <el-button type="primary" @click="showAddDialogForm" size="mini">新增</el-button>
            </el-form-item>
          </el-form> -->

          <el-form :inline="true" size="medium" :model="searchForm">
            <el-form-item>
              <el-button type="primary" @click="search" size="mini">刷新</el-button>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="settlement" size="mini">结算</el-button>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="pay" size="mini">支付</el-button>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" size="mini" @click="exportExcel">Excel导出</el-button>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
    </el-row>

    <el-table
      :data="tableData"
      :header-cell-style="{backgroundColor:'#f4f4f5',textAlign:'center'}"
      :cell-style="{textAlign:'center'}"
      :height="tableHeight"
      border
      @selection-change="handleSelectionChange"
      style="width: 100%">
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column
        prop="id"
        label="序号"
        type="index"
        width="80">
      </el-table-column>
      <el-table-column
        prop="carEnterpriseName"
        label="车企"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="brand"
        label="车企商标"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="customerName"
        label="业务经理"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="carName"
        label="车辆类别"
        min-width="120">
      </el-table-column>
      
      <el-table-column
        prop="productTypeName"
        label="申报类型"
        min-width="150">
        <template scope="scope">
          {{scope.row.productTypeName1+"/"+scope.row.productTypeName2}}
        </template>
      </el-table-column>
      <el-table-column
        prop=""
        label="检测项目统计"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="orderStatus"
        label="任务状态"
        min-width="120">
        <template scope="scope">
          {{orderStatus(scope.row.orderStatus)}}
        </template>
      </el-table-column>
      <!-- <el-table-column
        prop="brand"
        label="车企商标"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="customerName"
        label="客户名称"
        min-width="120">
      </el-table-column> -->
      <!-- <el-table-column
        prop="orgName"
        label="检测机构"
        min-width="120">
      </el-table-column> -->

      <!-- <el-table-column
        prop="productTypeName"
        label="产品类型"
        min-width="150">
        <template scope="scope">
          {{scope.row.productTypeName+"/"+scope.row.parentProductTypeName}}
          <template v-if="scope.row.hasDx">+定型</template>
        </template>
      </el-table-column> -->

      <!-- <el-table-column
        prop="testItems"
        label="检测项目"
        min-width="170">
        <template scope="scope">
          <span v-html="parseTestItem2(scope.row)"></span>
        </template>
      </el-table-column> -->

      <!-- <el-table-column
        prop="rebate"
        label="默认折扣"
        min-width="120">
        <template scope="scope">
          {{scope.row.rebate}}%
        </template>
      </el-table-column>
      <el-table-column
        prop="siteRebate"
        label="默认场地折扣"
        min-width="120">
        <template scope="scope">
          {{scope.row.siteRebate}}%
        </template>
      </el-table-column> -->
      <el-table-column
        prop="priceCost"
        label="成本总价"
        min-width="120">
        <template scope="scope">
          {{priceCost(scope.row.priceCost,scope.row.amount)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="payPriceCost"
        label="实际支付成本"
        min-width="120">
        <template scope="scope">
          {{payPriceCost(scope.row.priceCost,scope.row.payPriceCost,scope.row.amount)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="closingCost"
        label="成本费是否支付"
        min-width="120">
        <template scope="scope">
          {{closings(scope.row.closingCost)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="price"
        label="结算费用"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="payPrice"
        label="实际结算费用"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="closingPayPrice"
        label="是否结算费用"
        min-width="120">
        <template scope="scope">
          {{closing(scope.row.closingPayPrice)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="amount"
        label="其他费用"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="nums"
        label="报告份数"
        min-width="120">
        <template scope="scope">
          {{num(scope.row.nums,scope.row.productTypeId1)}}
        </template>
      </el-table-column>
      <!-- <el-table-column
        prop="isSend"
        label="是否送样"
        min-width="100">
        <template scope="scope">
          {{scope.row.isSend?"是":"否"}}
        </template>
      </el-table-column> -->


      <!-- <el-table-column
        prop="id"
        label="任务状态"
        min-width="120">
        <template scope="scope">
          <span v-if="scope.row.step == 0">未下发</span>
          <span v-if="scope.row.step == 1">已完成</span>
          <span v-if="scope.row.step == 2">工程师A</span>
          <span v-if="scope.row.step == 3">工程师B</span>
          <span v-if="scope.row.step == 4">工程师C</span>
          <span v-if="scope.row.stepStatus == 3">(回退)</span>
          <span v-if="scope.row.stepStatus == 4">(转交)</span>
        </template>
      </el-table-column> -->

      <el-table-column
        prop="updateTime"
        label="最后修改时间"
        min-width="160">
        <template scope="scope">
          {{fmtDate(scope.row.updateTime)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        min-width="160">
        <template scope="scope">
          {{fmtDate(scope.row.createTime)}}
        </template>
      </el-table-column>

      <el-table-column
        prop="note"
        label="备注"
        min-width="160">
      </el-table-column>
      <el-table-column
        prop="address"
        fixed="right"
        label="操作"
        min-width="250">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" @click="handlePriceOtherManage(scope.$index, scope.row)">其他费用管理</el-button>
          <el-button size="mini" type="primary" @click="updateLog(scope.$index, scope.row)">操作日志</el-button>
          <el-button style="margin-top:8px" size="mini" type="primary" @click="handleShowTask(scope.$index, scope.row)">查看任务</el-button>
          <template v-if="scope.row.orderStatus != 1">
            <!-- <el-button style="margin-top:8px" size="mini" type="primary" @click="handleOrderDone(scope.$index, scope.row)">任务单完成</el-button> -->
          </template>
          <template >
            <el-button size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">修改</el-button>
            <!-- <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
          </template>
          <!-- <template v-if="scope.row.step == 1||scope.row.step == 2||scope.row.step == 3||scope.row.step == 4">
            <el-button size="mini" type="primary" @click="handleShowData(scope.$index, scope.row)">数据</el-button>
          </template>
          <template v-if="scope.row.step == 2||scope.row.step == 3||scope.row.step == 4">
            <el-button size="mini" type="primary" @click="handleToUser(scope.$index, scope.row)">转交</el-button>
          </template> -->
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
       <span class="demonstration"></span>
       <el-pagination
         @size-change="handleSizeChange"
         @current-change="handleCurrentChange"
         :current-page="currentPage"
         :page-sizes="[10, 20, 50, 100,200]"
         :page-size="pageSize"
         layout="total, sizes, prev, pager, next, jumper"
         :total="total">
       </el-pagination>
     </div>

    <el-dialog :title="editForm.id==0?'新增':'修改'" :visible.sync="editFormVisible" width="500px" :close-on-click-modal="false">

      <el-form :model="editForm" ref="editForm" :rules="editRules">
        <el-form-item label="实际结算费用" label-width="100px" prop="payPrice">
          <el-input v-model="editForm.payPrice" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="实际支付成本" label-width="100px" prop="payPriceCost">
          <el-input v-model="editForm.payPriceCost" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="备注" label-width="100px">
          <el-input v-model="editForm.note" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editFormVisible = false">取 消</el-button>
        <el-button type="primary" @click.native.prevent="submitForm" :loading="loading">{{ editForm.id==0?'添 加':'修 改' }}</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import {validPhone} from '@/common/utils/validate.js'
import request from '@/common/utils/request.js'
import util from '../../../common/utils/util.js'
import {getToken} from '../../../common/utils/auth.js'
import {getTestOrderAllList, saveOrNextTestOrder, deleteTestOrder, taskToUser, getOrderInfo, orderNext, updateOrderPrice, doneOrder,updateOrderSettlement,updateOrderPay} from "../../../api/test_order.js";
import {getAllTestCarEnterpriseList} from "../../../api/test_car_enterprise.js"
import {getTestCarListByEntId} from "../../../api/test_car.js"
import {getAllCarTypeList} from '../../../api/car_type.js'
import {getAllTestProductTypeList} from '../../../api/test_product_type.js'
import {getAllTestGroupListByParam,getTestGroupItemParam} from '../../../api/test_group.js'
import {getAllTestSiteList} from '../../../api/test_site.js'
import {getTestSitePrice, getTestSiteItemList} from '../../../api/test_site_price.js'
import {getAllUserList} from '../../../api/user.js'
import {getAllTestOrgList} from '../../../api/test_org.js'
import {getTestItemList2, getTestItemListByGroupId} from '../../../api/test_item.js'
import axios from "axios";



export default {
  name: "testOrderManage3",
  data() {
    return {
      total: 0,
      pageSize: 10,
      currentPage: 1,
      tableData: [],
      tableHeight: 200,
      editFormVisible:false,
      loading: false,
      idList:[],
      editForm: {
        id: 0,
        // tOrderId:0,
        // carEnterpriseId:0,
        // testTasks:[],
        priceCost: 0, // 成本总价
        // price: 0, // 计算总价
        payPrice: 0, // 最终价
        // payPriceStatus: 0, // 最终价是否修改过
        // rebate: 100, // 车企默认折扣
        // siteRebate: 100, // 车企场地默认折扣
        // next: 0,
        amount:0,
        payPriceCost:0,
      },
      editRules: {
        carEnterpriseId: [{ required: true, message:"请选择车企", trigger: 'blur'}],
      },
      loadingDiv: null,
      searchForm: {
        orderStatus: 0,
      },
      carEntList:[],
      carList:[],
      carTypeList:[],
      testProductTypeList: [],
      groupList: [],
      groupItemList:[],
      testSiteList:[],
      userList:[],
      orgList:[],
      hasDxDisabled:true,
      nextShow: false,

      showEditTaskDialog: false,
      editTaskIndex: -1,
      editTaskForm: {
        id: 0,
        tid:0,
        tOrderId: 0,
        carTypeId: '', // 车型
        carTypeName: '',
        productTypeId1: '', // 产品类别1级分类
        productTypeId2: '', // 产品类别2级分类
        productTypeName1: '',
        productTypeName2: '',
        siteId: '',
        orgId: '',
        groupId: '', // 套餐id
        groupName: '',
        groupPrice: '',
        groupItemIds: [],
        groupItemTIds: [],
        priceItemCost: 0,
        priceSiteCost: 0,
        priceItemPay: 0,
        priceSitePay: 0,

        note: '',
        testItems:[],
        productTypeIds:[],

        a: '',
        b: '',
        c: '',
        d: '',
        e: '',
        f: '',
        g: '',
        h: '',
        i: '',
        j: '',

        //公告：ABCDEF 1
        //达标：ABDEFCGHI 2
        //CCC：ABFC 3
        //环保：ABF 4
        //其他：ABFJ 19
      },
      editTaskRules: {
        carTypeId: [{ required: true, message:"请选择车企", trigger: 'blur'}],
        productTypeIds: [{ required: true, message:"请选择产品类型", trigger: 'blur'}],
        siteId: [{ required: true, message:"请选择检测场地", trigger: 'blur'}],
        orgId: [{ required: true, message:"请选择检测机构", trigger: 'blur'}],
        testItems: [{ required: true, message:"请添加检测项目", trigger: 'blur'}],
      },

      showAddItemDialog: false,
      addItemForm:{
        items:[]
      },
      addItems:[],

      siteItemList: [],

      multipleSelection: []
    }
  },
  watch:{
    $route (to, from ) {
      // 监听路由变化, 实现类似 小程序的 onShow 事件
      if (to.path === '/task/test_order_manage/0') {
        if(this.nextShow){
          this.editFormVisible = true;
          this.nextShow = false;
        }
      }
    }

  },
  computed:{
    carEntDisabled(){
      if(this.editForm.testTasks && this.editForm.testTasks.length > 0){
        return true;
      }
      return false;
    }
  },
  created() {
    let step=this.$route.params.step;
    if(step == 0){
      this.searchForm.orderStatus=0;
    }else if(step == 1){
      this.searchForm.orderStatus=1;
    }else if(step == 2){
      this.searchForm.orderStatus=2;
    }
  },
  mounted() {
    this.init();
    this.getDataList(this.currentPage);

    this.$nextTick(() => {
        this.tableHeight = document.documentElement.clientHeight - 198;
    })
    window.onresize = () => {
      this.$nextTick(() => {
          this.tableHeight = document.documentElement.clientHeight - 198;
      })
    }

    let t = getToken();
    this.fileBaseUrl = this.$adminApiUrl+"/file/get?_t="+t+"&f=";
  },
  methods: {
    //结算
    settlement(){
      var id=[];
      for(var i=0;i<this.multipleSelection.length;i++){
        id.push(this.multipleSelection[i].id)
      }
      console.log(id)
      this.idList = id;
      console.log(this.idList)
          updateOrderSettlement({idList:this.idList}).then(res => {
          if(res.code == 0) {
            this.$alert(res.msg, "保存失败", {dangerouslyUseHTMLString:true,type:'warning'})
          }else if(res.code == 1) {
            this.$alert(res.msg, "保存成功", {dangerouslyUseHTMLString:true,type:'success'})
              .then(()=> {
                this.editFormVisible=false;
                this.getDataList(this.currentPage)
              })
          }

        })
    },
    pay(){
      let id=[];
      for(var i=0;i<this.multipleSelection.length;i++){
        id.push(this.multipleSelection[i].id)
      }
      this.idList = id;
          updateOrderPay({idList:this.idList}).then(res => {
          if(res.code == 0) {
            this.$alert(res.msg, "保存失败", {dangerouslyUseHTMLString:true,type:'warning'})
          }else if(res.code == 1) {
            this.$alert(res.msg, "保存成功", {dangerouslyUseHTMLString:true,type:'success'})
              .then(()=> {
                this.editFormVisible=false;
                this.getDataList(this.currentPage)
              })
          }

        })
    },

    handleEdit(index, row) {

    	if(this.$refs.editForm){
    		this.$refs.editForm.clearValidate();
    	}
    	this.editForm.id = row.id;
    	this.editForm.payPrice = row.payPrice;
    	this.editForm.note = row.note;
      if(row.payPriceCost==null||row.payPriceCost==0){
        this.editForm.payPriceCost = row.priceCost+row.amount;
      }else{
        this.editForm.payPriceCost = row.payPriceCost;
      }

    	this.editFormVisible = true;
      this.editForm.amount = row.amount;

    },

    exportExcel(){
      const loadingDiv = util.showLoading("正在导出EXCEL")

      let param = {};
      // param['siteId'] = this.$route.params.id;
      // console.log(param);

      let t = getToken();
      let headers = {"x-token": t};
      axios({
        method: 'post',
        url: this.$adminApiUrl + "/test-order/all-excel-export", // 请求地址

        data: param, // 参数
        headers: headers,
        responseType: 'blob' ,// 表明返回服务器返回的数据类型

      }).then(res=>{
        loadingDiv.close();
        let blob = new Blob([res.data], { type: 'application/xlsx' })
        let url = window.URL.createObjectURL(blob)
        const link = document.createElement('a') // 创建a标签
        link.href = url;
        let timeStr = "";//this.fmtDate(new Date(),"yyyyMMdd_hhmmss");
        link.download = '全部任务'+ '.xlsx' // 重命名文件
        link.click()
        URL.revokeObjectURL(url)

      }).catch(err=>{
        console.log(err);
        loadingDiv.close();
        this.$alert("导出失败,请检查网络", {dangerouslyUseHTMLString:true,type:'warning'})
      });
    },

    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleShowTask(index, row){
      let item = {
        componentName:"taskManage",
        icon:"",
        path:"/task/task_manage/"+row.tOrderId+"/"+row.carEnterpriseId,
        title: "查看任务",
      };

      this.$store.commit("openTab",{item:item, router: (path)=>{this.$router.replace(path)}})
    },
    handleOrderDone(index, row){
      const loadingDiv = util.showLoading("任务单完成中")
      this.loading = true;
      doneOrder({tOrderId: row.tOrderId}).then(res => {
        if(res.code == 0) {
          this.$alert(res.msg, "失败", {dangerouslyUseHTMLString:true,type:'warning'})
        }else if(res.code == 1) {
          this.$alert(res.msg, "成功", {dangerouslyUseHTMLString:true,type:'success'})
            .then(()=> {
              this.editFormVisible=false;
              this.getDataList(this.currentPage)
            })
        }
        this.loading = false;
        loadingDiv.close();
      }).catch(res => {
        this.loading = false;
        loadingDiv.close();
      })
    },
    handleOrderEdit(index, row){
      console.log("修改");
      getOrderInfo({id: row.id}).then(res=>{
        console.log(res.data);
        this.editForm = res.data;

        if(!util.isEmpty(this.editForm.testTasks)){
          for(let i in this.editForm.testTasks){
            let tasks = this.editForm.testTasks[i];
            if(!util.isEmpty(tasks.groupItemTIds)){
              let arrStr = tasks.groupItemTIds.split(",")
              let arr = [];

              for(let i in arrStr){
                if(!util.isEmpty(arrStr[i])){
                  arr.push(parseInt(arrStr[i]));
                }
              }

              tasks.groupItemTIds = arr;
            }
          }
        }

        this.editFormVisible = true;
      })
    },
    init(){
      getAllTestCarEnterpriseList().then(res => {
        if(res.code == 1) {
          this.carEntList = res.data;
        }
      }).catch(res => {

      })
      this.getAllCarTypeList();

      // 获取所有检测产品类别
      getAllTestProductTypeList().then(res => {
        if(res.code == 1) {
          this.testProductTypeList = res.data;
        }
      }).catch(res => {

      });

      // 获取所有检测场地
      getAllTestSiteList().then(res => {
        if(res.code == 1) {
          this.testSiteList = res.data;
        }
      }).catch(res => {

      });

      // 获取所有用户列表
      getAllUserList().then(res => {
        if(res.code == 1) {
          this.userList = res.data;
        }
      }).catch(res => {

      });

      getAllTestOrgList().then(res => {
        if(res.code == 1) {
          this.orgList = res.data;
        }
      }).catch(res => {

      });

    },
    getAllCarTypeList(){
      getAllCarTypeList().then(res=>{
        if(res.code == 1) {
          this.carTypeList = res.data;
        }
      }).catch(res => {

      })
    },
    refreshCarEntList(){
      getAllTestCarEnterpriseList().then(res => {
        if(res.code == 1) {
          this.carEntList = res.data;
          this.$message({
            showClose: true,
            message: "刷新成功",
            type: 'success'
          });
        }
      }).catch(res => {

      })
    },
    handlerOpenPage(t){

      let item = {};

      switch(t){
        case 1: // 跳转到车型管理
          item = {
            componentName:"testCarEnterpriseManage",
            icon:"",
            path:"/base/test_car_enterprise_manage",
            title: "车型类别管理",
          };
          break;
        case 2: // 跳转到车辆管理
          item = {
            componentName:"testCarManage",
            icon:"",
            path:"/test_car/test_car_manage",
            title: "车辆管理",
          };
          break;
      }

      this.editFormVisible=false;
      this.nextShow = true;
      this.$store.commit("openTab",{item:item, router: (path)=>{this.$router.replace(path)}});

      // window.open("/#/base/car_type_manage");
    },


    fmtDate(d2, fmt) { // yyyy-MM-dd hh:mm:ss
      if (util.isEmpty(d2) || d2 <= 0){
        return "";
      }
      return  util.fmtDate(new Date(d2), fmt);
    },

    closing(data) { // yyyy-MM-dd hh:mm:ss
      if (data==0){
        return "未结算";
        }else{
          return "已结算";
        }

    },
    closings(data) { // yyyy-MM-dd hh:mm:ss
      if (data==0){
        return "未支付";
        }else{
          return "已支付";
        }
    },
    orderStatus(data){
      if (data==0){
        return "未开始";
        }else if(data==1){
          return "已完成";
        }else{
          return "进行中";
        }
    },
    num(num,productTypeId1){

      let arrTemp = productTypeId1.split(",");
      let m = 0;
      arrTemp = arrTemp.map(Number);

      for(var i=0;i<arrTemp.length;i++){
        if(arrTemp[i]==2){
          m = m+1
        }
      }
      return num-m;
    },

    priceCost(priceCost,amount){
      return priceCost+amount
    },

    payPriceCost(priceCost,payPriceCost,amount){
      if(payPriceCost==null||payPriceCost==0){
        return priceCost+amount;
      }else{
        return payPriceCost;
      }
    },

    submitForm() {
      //this.editForm.next = 0;
      if(this.editForm.id == 0){
        this.saveOrNext();
      }else{
        this.updateOrderPrice();
      }

    },
    updateOrderPrice(){
      const loadingDiv = util.showLoading("保存中")
      this.loading = true;
      updateOrderPrice(this.editForm).then(res => {
        if(res.code == 0) {
          this.$alert(res.msg, "保存失败", {dangerouslyUseHTMLString:true,type:'warning'})
        }else if(res.code == 1) {
          this.$alert(res.msg, "保存成功", {dangerouslyUseHTMLString:true,type:'success'})
            .then(()=> {
              this.editFormVisible=false;
              this.getDataList(this.currentPage)
            })
        }
        this.loading = false;
        loadingDiv.close();
      }).catch(res => {
        this.loading = false;
        loadingDiv.close();
      })
    },
    submitFormNext() {
      this.editForm.next = 1;
      this.saveOrNext();
    },

    saveOrNext(){

      this.$refs.editForm.validate(valid => {
        if(valid) {
          this.loading = true;
          let loadingText = "保存中...";
          if(this.editForm.next == 1){
            loadingText = "下发中...";
          }
          const loadingDiv = util.showLoading(loadingText)
          saveOrNextTestOrder(this.editForm).then(res => {
            let title = "保存"
            if(this.editForm.next == 1){
              title = "下发"
            }
            if(res.code == 0) {
              this.$alert(res.msg, title+"失败", {dangerouslyUseHTMLString:true,type:'warning'})
            }else if(res.code == 1) {
              this.$alert(res.msg, title+"成功", {dangerouslyUseHTMLString:true,type:'success'})
                .then(()=> {
                  this.editFormVisible=false;
                  this.getDataList(1)
                })
            }
            this.loading = false;
            loadingDiv.close();
          }).catch(res => {
            this.loading = false;
            loadingDiv.close();
          })
        }
      });
    },

    handleDelete(index, row) {
      let loadingDiv;
      this.$confirm("是否确认删除?","删除确认").then(res=>{
        if(res='confirm'){
          loadingDiv = util.showLoading("删除中...")
          return deleteTestOrder({id: row.id})
        }
      }).then(res => {
        loadingDiv.close();
        if(res.code == 0) {
          this.$alert(res.msg, "删除失败", {dangerouslyUseHTMLString:true,type:'warning'})
        }else if(res.code == 1) {
          this.$alert(res.msg, "删除成功", {dangerouslyUseHTMLString:true,type:'success'})
            .then(res=>{
              this.editFormVisible=false;
              this.getDataList(this.currentPage)
            })
        }
      }).catch(res=>{
        if (loadingDiv){
          loadingDiv.close();
        }
      })
    },
    getDataList(pageNum){
      const loadingDiv = util.showLoading()

      getTestOrderAllList({
        pageSize: this.pageSize,
        pageNum: pageNum,
        orderStatus: this.searchForm.orderStatus,
      }).then(res => {
        if(res.code == 0) {
          this.$message({
            showClose: true,
            message: res.msg,
            type: 'error'
          });
        }else if(res.code == 1) {
          let data = res.data;
          this.currentPage = pageNum;
          this.total = data.total;
          this.tableData = data.dataList;
        }
        loadingDiv.close();
      }).catch(res => {
        loadingDiv.close();
      })
    },
    search() {
      this.getDataList(1)
    },
    handleSizeChange(pageSize) {
            this.pageSize = pageSize;
            this.getDataList(1)
          },
    handleCurrentChange(pageNum) {
            this.getDataList(pageNum);
          },
    handlePriceOtherManage(index, row){
      let item = {
        componentName:"priceOtherManage",
        icon:"",
        path:"/task/price_other_manage/"+row.tOrderId,
        title: "其他费用管理",
      };

      this.$store.commit("openTab",{item:item, router: (path)=>{this.$router.replace(path)}})
    },
    updateLog(index, row){
      let item = {
        componentName:"updateLog",
        icon:"",
        path:"/task/update_log/"+row.tOrderId,
        title: "操作日志",
      };

      this.$store.commit("openTab",{item:item, router: (path)=>{this.$router.replace(path)}})
    },
    handleOrderTask(index, row){
      // let item = {
      //   componentName:"testOrderTaskManage",
      //   icon:"",
      //   path:"/task/test_order_task_manage/"+row.tOrderId,
      //   title: "任务下发",
      // };

      // this.$store.commit("openTab",{item:item, router: (path)=>{this.$router.replace(path)}})

    },
  }
}
</script>

<style scoped lang="scss">
  // @import "~@/common/styles/element-variables.scss";
  .search-box {
    background-color: #FFFFFF;
    min-height: 36px;
    line-height: 36px;
    padding-top: 2px;
    padding-bottom: 6px;
    .el-form-item {
      margin-bottom: 0px !important;
    }
    .el-form--inline {
      display: inline-block;
    }
  }
  .pagination-box {
    text-align: left;
    margin-top: 10px;
  }
  .test-item-table{
    width: 100%;
    border-collapse: collapse;

    th, td {
      width: 7%;
      text-align: center;
      border: 1px solid #CCC;
    }
    th {
      background-color: #EDF2FC;
    }
  }
  .chose-role{
    display: inline-block;
    margin-left: 20px;
    margin-bottom: 20px;
  }
</style>
<style lang="scss">
  .el-dialog__header {

  }
  .el-dialog__body {
    padding-top: 10px;
    padding-bottom: 0px;
  }
  .el-dialog__footer {
    padding-top: 0px;
  }
</style>
